package app

import (
	"github.com/gin-contrib/cors"
	"github.com/gin-gonic/gin"
	"main/api/middleware"
)

//定义Init 函数初始化
type Option func(*gin.Engine)

var options = []Option(nil)

func Include(opts ...Option) {
	options = append(options, opts...)
}

// 初始化
func Init() *gin.Engine {
	// 默认引擎
	//r := gin.Default()
	r := gin.Default()
	//RegisterValidation()
	r.Use(cors.Default())
	r.Use(middleware.MiddleWare())
	for _, opt := range options {
		opt(r)
	}
	return r
}
